package com.controller.information;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.po.CommentInfo;
import com.po.CommentSpecialistInfo;
import com.service.information.CommentService;
import com.service.information.CommentSpecialistService;
import com.util.UUIDGenerator;

@Controller
@RequestMapping("/jsp/information")
public class CommentController {
	@Resource(name = "commentServiceImp")
	private CommentService commentService;
	@Resource(name = "commentSpecialistServiceImp")
	private CommentSpecialistService commentSpecialistService;
	
	// 获取第一级评论列表(专家)
	@ResponseBody
	@RequestMapping(value = "/getCommentSpecialistList")
	public List<CommentSpecialistInfo> getCommentSpecialistList(CommentSpecialistInfo commentSpecialistInfo) {
		List<CommentSpecialistInfo> list = commentSpecialistService.getCommentSpecialistList(commentSpecialistInfo);
		return list;
	}

	// 添加评论(专家)
	@ResponseBody
	@RequestMapping(value = "/addCommentSpecialist")
	public int addCommentSpecialist(HttpServletRequest request, CommentSpecialistInfo commentSpecialistInfo) {
		String userid = request.getSession().getAttribute("user_id").toString();
		commentSpecialistInfo.setComment_specialist_userid(userid);
		String commentid = UUIDGenerator.getUUID();
		commentSpecialistInfo.setComment_specialist_id(commentid);
		int info = commentSpecialistService.addCommentSpecialist(commentSpecialistInfo);
		return info;
	}

	// 删除评论(专家)
	@ResponseBody
	@RequestMapping(value = "/deleteCommentSpecialist")
	public int deleteCommentSpecialist(String id) {
		int i = commentSpecialistService.deleteCommentSpecialist(id);
		return i;
	}

	// 评论(专家)
	@ResponseBody
	@RequestMapping(value = "/getCommentSpecialistCount")
	public int getCommentSpecialistCount(CommentSpecialistInfo commentSpecialistInfo) {
		int i = commentSpecialistService.getCommentSpecialistCount(commentSpecialistInfo);
		return i;
	}
	
	
	
	
	
	
	// 获取第一级评论列表
	@ResponseBody
	@RequestMapping(value = "/getCommentList")
	public List<CommentInfo> getCommentList(CommentInfo commentInfo) {
		List<CommentInfo> list = commentService.getCommentList(commentInfo);
		return list;
	}

	// 添加评论
	@ResponseBody
	@RequestMapping(value = "/addComment")
	public int addComment(HttpServletRequest request, CommentInfo commentInfo) {
		String userid = request.getSession().getAttribute("user_id").toString();
		commentInfo.setComment_userid(userid);
		String commentid = UUIDGenerator.getUUID();
		commentInfo.setComment_id(commentid);
		int info = commentService.addComment(commentInfo);
		return info;
	}
	//删除评论
	@ResponseBody
	@RequestMapping(value = "/deleteComment")
	public int deleteComment(String id) {
		int i = commentService.deleteComment(id);
		return i;
	}
	
	// 删除评论
	@ResponseBody
	@RequestMapping(value = "/getCommentCount")
	public int getCommentCount(CommentInfo commentInfo) {
		int i = commentService.getCommentCount(commentInfo);
		return i;
	}
}
